<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8">
    <title>Retina Dashboard</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta name="robots" content="" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="/static/css/style.css" media="all" />

    <script src="/static/js/jquery-1.10.1.min.js"></script>
    <script src="/static/js/jquery.wysiwyg.js"></script>
    <script src="/static/js/jquery.checkbox.min.js"></script>

    <script src="/static/js/jquery.tablesorter.min.js"></script>
    <style type="text/css">


    </style>
</head>
<body>
<div class="testing">
    <header class="main">
        <h1><strong>Retina</strong> Dashboard</h1>
    </header>
    <section class="user">
        <div class="buttons">
            <span class="button blue"><a href="/admin/login_out/{{.tel}}">登出</a></span>
        </div>
    </section>
</div>
<nav>        <!--左侧导航部分-->
    <ul>
        <li><a href="/admin/index/{{.tel}}"><span class="icon">&#128711;</span> 设备监控</a></li>
        <li ><a href="/admin/admin_list/{{.tel}}"><span class="icon">&#128101;</span>管理员</a></li>
        <li>
            <a href="/admin/sys_setting/{{.tel}}"><span class="icon">&#9881;</span>系统设置</a>
        </li>
        <li>
            <a href="/admin/show_remote_list/{{.tel}}"><span class="icon">&#9881;</span>显示遥控数据</a>
        </li>
        <li>
            <a href="/admin/add_remote_data/{{.tel}}"><span class="icon">&#9881;</span>添加遥控数据</a>
        </li>
        <li class="section">
            <a href="/admin/app_list/{{.tel}}"><span class="icon">&#9881;</span>app版本管理</a>
        </li>
    </ul>
</nav>

<section class="alert">
    <button onclick="{location.href='/admin/upload_new_app/{{.tel}}'}"   class="green">添加新版本app</button>
    <button id="del_btn" class="green">删除</button>
</section>
<section class="content">
    <section class="widget">
        <header>
            <span class="icon">&#128100;</span>
            <hgroup>
                <h1>管理员</h1>
            </hgroup>
        </header>
        <div class="content">
            <table id="myTable" border="0" width="100">
                <thead>
                <tr>
                    <th>选中</th>
                    <th class="avatar">app名字</th>
                    <th>版本号</th>
                    <th>更新的日期</th>
                </tr>
                </thead>
                <tbody id="user_list">

                </tbody>
            </table>
        </div>
    </section>
</section>

<script type="text/javascript">
$(function () {
    var tel = {{.tel}}
    $(document).ready(function() {
     $.getJSON('http://'+window.location.host+'/admin/api/get_app_list/'+tel, function(data) {
			console.log(data)
        	$.each(data.List,function(index,element){
				    $("#user_list").append('<tr><td><input type="checkbox" name="checkbox" id="'+element.Id+'"></td>'+'<td class="avatar">'+ element.AppName+'</td><td>'+element.Version+'</td><td>'+element.UpdateTime+'</td></tr>')

			});
    	});

    });

});
</script>

<script type="text/javascript">
    $(document).ready(function() {

        $("#del_btn").click(function(){
        var objs = $(":input[type='checkbox'][name='checkbox']")
        var ids = {"Ids":[]};
            var num = objs.length

            for(var i=0;i< num;i++){
                    if(objs[i].checked == true){
                        console.log(objs[i].id)
                        ids.Ids.push(parseInt(objs[i].id))
                 }
             }
            if (ids.Ids.length <= 0){
                alert("选中一个你要删除的版本");
                return false
            }

		            $.ajax({
                        url:'http://'+window.location.host+'/admin/api/del_apps/'+{{.tel}},
                        type:"POST",
                        dataType:"json",
                        data:JSON.stringify(ids),
                        success: function(data){
                               if(data.RespCode == 205){
                                    alert("有帐号删除失败");
                                    window.location.reload()
                               }else if((data.RespCode == 200)){
                                    window.location.reload()
                               }
                        }
		            });


        });
});
</script>

</body>
</html>